package com.ruoyi.web.controller.camera;


import java.util.List;

import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.CarmerasAbility;
import com.ruoyi.system.service.ICarmerasAbilityService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
/**
 * 摄像头能力Controller
 *
 * @author ruoyi
 * @date 2021-03-15
 */
@RestController
@RequestMapping("/system/ability")
public class CarmerasAbilityController extends BaseController
{
    @Autowired
    private ICarmerasAbilityService carmerasAbilityService;

    /**
     * 查询摄像头能力列表
     */
    @PreAuthorize("@ss.hasPermi('system:ability:list')")
    @GetMapping("/list")
    public TableDataInfo list(CarmerasAbility carmerasAbility)
    {
        startPage();
        List<CarmerasAbility> list = carmerasAbilityService.selectCarmerasAbilityList(carmerasAbility);
        return getDataTable(list);
    }
    /**
     * 查询摄像头能力列表
     */
    @PreAuthorize("@ss.hasPermi('system:ability:list')")
    @GetMapping("/listAbilityByCarmId")
    public TableDataInfo listAbilityByCarmId(CarmerasAbility carmerasAbility)
    {
        startPage();
        List<CarmerasAbility> list = carmerasAbilityService.listAbilityByCarmId(carmerasAbility);
        return getDataTable(list);
    }

    /**
     * 导出摄像头能力列表
     */
    @PreAuthorize("@ss.hasPermi('system:ability:export')")
    @Log(title = "摄像头能力", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CarmerasAbility carmerasAbility)
    {
        List<CarmerasAbility> list = carmerasAbilityService.selectCarmerasAbilityList(carmerasAbility);
        ExcelUtil<CarmerasAbility> util = new ExcelUtil<CarmerasAbility>(CarmerasAbility.class);
        return util.exportExcel(list, "ability");
    }

    /**
     * 获取摄像头能力详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ability:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(carmerasAbilityService.selectCarmerasAbilityById(id));
    }

    /**
     * 新增摄像头能力
     */
    @PreAuthorize("@ss.hasPermi('system:ability:add')")
    @Log(title = "摄像头能力", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CarmerasAbility carmerasAbility)
    {
        return toAjax(carmerasAbilityService.insertCarmerasAbility(carmerasAbility));
    }

    /**
     * 修改摄像头能力
     */
    @PreAuthorize("@ss.hasPermi('system:ability:edit')")
    @Log(title = "摄像头能力", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CarmerasAbility carmerasAbility)
    {
        return toAjax(carmerasAbilityService.updateCarmerasAbility(carmerasAbility));
    }

    /**
     * 删除摄像头能力
     */
    @PreAuthorize("@ss.hasPermi('system:ability:remove')")
    @Log(title = "摄像头能力", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(carmerasAbilityService.deleteCarmerasAbilityByIds(ids));
    }
}
